package top.fullj.actor.mq;

class Subscription<T> implements Subscribable<T> {

    private final Fiber fiber;
    private final Action<T> receiver;

    Subscription(Fiber fiber, Action<T> receiver) {
        this.fiber = fiber;
        this.receiver = receiver;
    }

    @Override
    public void onMessage(final T msg) {
        fiber.execute(() -> receiver.onMessage(msg));
    }

}
